package com.fandy.struts.DAL;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.fandy.struts.SqlAccess.SqlServerHelper;
import com.fandy.struts.SqlStatement.Message;
 

public class DALMessage {
 
	SqlServerHelper ssh = new SqlServerHelper();
	Message m = new Message(); 
	
	public   ResultSet getMessageByID(int ID)
	{
		return ssh.executeScalar(m.getMessageByID(ID));
	}

	public int Add(com.fandy.struts.Model.Message msg) throws SQLException
	{
		
		return  ssh.executeNoQuery(m.Add(msg));
		
	}
	
	public   ResultSet getAllMyMessages(int UserID)
	{
		return  ssh.executeScalar(m.getAllMyMessages(UserID));
	}

	public   ResultSet getAllMessagesSended(int UserID)
	{
		return  ssh.executeScalar(m.getAllMessagesSended(UserID));
	}
	
		
//	public String UpdateByID(int id,com.fandy.struts.Model.Message s)
//	{
//		
//		return "update GoodsInfo set "+com.fandy.struts.Meta.Message.getDetail()
//		+"='" + s.getDetail()+"',"		 
//		+com.fandy.struts.Meta.Message.get+"='" +s.getAuthority()+"',"
//		+com.fandy.struts.Meta.Message.getContact()+ "='"  + s.getContact() + "',"
//		+com.fandy.struts.Meta.Message.getDepartmentid()+ "='"  + s.getDepartmentid() + "',"
//		+com.fandy.struts.Meta.Message.getName() + "='"  + s.getName() + "',"
//		+com.fandy.struts.Meta.Message.getPassword() + "='"  + s.getPassword() + "',"
//		+com.fandy.struts.Meta.Message.getSalary() + "='"  + s.getSalary()+ "'"		
//		+"where "+com.fandy.struts.Meta.Message.getMessageid()+"="+id;
//		
//	}
	
	public int DeleteByID(int id) throws SQLException
	{
		
		return ssh.executeNoQuery(m.DeleteByID(id));
		
	}
	
	
	
}

